﻿using UnityEngine;
using System.Collections;

public class FollowMousy : MonoBehaviour {

	public BoxCollider2D HideTriggerOnPosX;
	public float distanceFromCamera = 1.0f;

	public SpriteRenderer aim;
	public SpriteRenderer command;

	public enum mousyState {
		Aim,
		Command
	};
	private mousyState state = mousyState.Aim;

	public mousyState getState (){
		return state;
	}

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		var z = transform.position.z;
		var pos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distanceFromCamera);
		pos = Camera.main.ScreenToWorldPoint(pos);
		pos.z = z;
		transform.position = pos;

		if (transform.position.x <= HideTriggerOnPosX.bounds.center.x + (HideTriggerOnPosX.bounds.size.x/2.0f)) {
			if(command) command.transform.localScale = new Vector3(1, 1, 1);
			if(aim) aim.transform.localScale = new Vector3 (0, 0, 0);
			state = mousyState.Command;
		} else {
			if(aim) aim.transform.localScale = new Vector3(1, 1, 1);
			if(command) command.transform.localScale = new Vector3 (0, 0, 0);
			state = mousyState.Aim;
		}
	}
}
